//
//  CodeWithDES.m
//  Contractor
//
//  Created by 金鑫 on 16/4/28.
//  Copyright © 2016年 star j. All rights reserved.
//

#import "CodeWithDES.h"
#import "DESEncryptFile.h"

@implementation CodeWithDES

//DES+Base64解密
+ (NSString *)decodeWithStr:(NSString *)str
{
    NSString *decodeStr = [DESEncryptFile textFromBase64String:str withKey:@"sanzhiniu34hao"] ;
    return decodeStr ;
}

//DES+Base64加密
+ (NSString *)encodeWithDic:(NSDictionary *)dic
{
    NSData *jsondata = [NSJSONSerialization dataWithJSONObject:dic options:NSJSONWritingPrettyPrinted error:nil] ;
    NSString *jsonStr = [[NSString alloc] initWithData:jsondata encoding:NSUTF8StringEncoding] ;
    NSString *encodeStr = [DESEncryptFile base64StringFromText:jsonStr withKey:@"sanzhiniu34hao"] ;
    return encodeStr ;
}


@end
